package 蓝桥杯.第十三届蓝桥杯大赛软件赛省赛Java大学B组;

import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

/**
 * @Title: 最少刷题数
 * @Author 贾金博
 * @Package 蓝桥杯.第十三届蓝桥杯大赛软件赛省赛Java大学B组
 * @Date 2024/4/10 21:06
 * @description: 1e5的限制
 */
public class 最少刷题数 {
    public static int n;
    public static int[] a;
    public static int[] b;
    public static int[] sum = new int[100010];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         n = sc.nextInt();
         a = new int[n + 10];
         b = new int[n + 10];
         Set<Integer> se = new TreeSet<>();

        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
            b[i] = a[i];
            sum[a[i]] += 1;
            se.add(a[i]);
        }
        int last;
        Object[] array = se.toArray();
        last = (Integer)array[se.size() / 2];
        Arrays.sort(b, 1, n + 1); // 注意 是前闭后开
//        for(int i = 1; i <= n; ++ i ) {
//            System.out.print(b[i] + " ");
//        }
//        System.out.println();
        for(int i = 1; i <= n; ++ i ) {
            int x = a[i];
            if(x >= last) { // 中间的位置
                System.out.print(0 + " ");
            } else {
//                int t = last - x;
                int t = 1;
                for(; ; ++ t ) {
                    // 这一点是比较耗时间的
                    if(check(x + t, x)) {
                        break;
                    }
                }
                System.out.print(t + " ");
            }
        }
    }

    public static boolean check(int x, int p) {
        int l = 0, r = n + 1;
        int ll, rr;

        //最后一个小于x的数的下标
        while(l + 1 < r) {
            int mid = (l + r) >> 1;
            if(b[mid] < x)l = mid;
            else r = mid;
        }
        ll = l;
//        System.out.println("b[ll] = " + b[ll]);
//        System.out.println("ll = " + ll);
        //第一个大于x的数的下标
        l = 1;
        r = n;
        while(l + 1 < r) {
            int mid = (l + r) >> 1;
            if(b[mid] <= x) l = mid;
            else r = mid;
        }
        rr = r;
       //System.out.println("x = " + x + " l = " + (ll - 1) + " r = " + (n - rr + 1));
        if(n - rr + 1  <= ll - 1) {
            return true;
        } else {
            return false;
        }
    }
}
/**
 * 4
 * 1 2 3 4
 *
 *
 *
 */
